<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>平时成绩管理系统-学生管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
</head>
<body>

<div class="layui-form"  id="layuiadmin-form-student"
     style="padding: 20px 0 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">导入类型</label>
        <div class="layui-input-block">
            <select  name="importType" id="importType">
                <option value="STUDENT">学生</option>
                <option value="TEACHER">教师</option>
                <option value="SCORE">成绩</option>
            </select>
        </div>
    </div>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend>拖拽上传</legend>
    </fieldset>
    <div class="layui-form-item">
        <label class="layui-form-label">EXCEL</label>
        <div class="layui-upload-drag" id="upload" style="margin-top: 60px">
            <i class="layui-icon"></i>
            <p>点击上传，或将文件拖拽到此处</p>
            <div class="layui-hide">
                <hr>
                <img src="" alt="上传成功后渲染" style="max-width: 196px">
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button"  lay-submit lay-filter="LAY-user-export-submit"  id="LAY-user-export-submit" value="确认">
    </div>
</div>

<script src="../../layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '../../layuiadmin/'
    }).extend({
        index: 'lib/index'
    }).use(['index', 'form', 'upload', 'laytpl'], function () {
        let $ = layui.$
            , setter = layui.setter
            , laytpl = layui.laytpl
            , form = layui.form
            , upload = layui.upload;

        upload.render({ //允许上传的文件后缀
            elem: '#upload'
            , url: setter.baseUrl + '/excel/import'
            ,accept: 'file' //普通文件
            ,exts: 'xlsx' //只允许上传xlsx文件
            ,before: function(obj){
                layer.load(); //上传loading
                this.data={'importType':$("#importType").val()};
            }
            ,done: function(res){
                layer.msg('上传成功');
                console.log(res)
            }
        });


        upload.render({
            elem: '#layuiadmin-upload-img'
            , url: setter.baseUrl + '/uploadImg'
            , accept: 'images'
            , method: 'post'
            , acceptMime: '/static/img/*'
            , done: function (res) {
                $(this.item).prev("div").children("input").val(res.data)
            }
        });
    })
</script>
</body>
</html>
